﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using devtm.Collections;
using CustomTypes.Interfaces.Structure;

namespace CSharpParser.Structure
{

    [Serializable]
    public class MemberCSharpStructure : TableCollection<IMemberStructure, string>, IMemberStructure
    {

        public MemberCSharpStructure(IMemberStructure parent, string name, string key) : base( c => c.Key)
        {
            Parent = parent;

            this.Name = name;
            Key = string.IsNullOrEmpty(key) ? name : key;

            if (parent != null && !string.IsNullOrEmpty(key))
                if (!parent.ContainsKeyFrom(this))                
                    parent.Add(this);
                
                else
                {

                }

            Locations = new List<Location>();
            Documentation = string.Empty;

        }


        /// <summary>
        /// Gets or sets the parent.
        /// </summary>
        /// <value>The parent.</value>
        public IMemberStructure Parent { get; private set; }

        public string Key { get; set; }

        public List<Location> Locations { get; set; }

        public string Documentation { get; set; }

        public string Name { get; set; }

        public MemberVisibility Accessibility { get; set; }

        public string MemberType { get; set; }

        public string FullName
        {
            get 
            {
                string p = string.Empty;
                
                if (Parent != null)
                {

                    p = Parent.FullName;

                    if (!string.IsNullOrEmpty(p))
                        p += ".";

                    p += Name;
                }
                else
                {
                    p += Name;
                }
                return p;
            }
        }

        public string CSharpString { get; set; }

    }


   



}
